package com.zidongxiangxi.clock.http;

import com.zidongxiangxi.clock.http.client.ClockClient;
import com.zidongxiangxi.clock.http.entity.ClockHttpProperties;
import feign.Feign;
import feign.Request;
import feign.Retryer;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * This is Description
 *
 * @author chenxudong
 * @date 2021/12/28
 */
@Configuration
@EnableConfigurationProperties({ClockHttpProperties.class})
public class ClockHttpAutoConfiguration {
    @Bean
    public ClockClient clockClient(ClockHttpProperties properties) {
        return Feign.builder()
            .options(new Request.Options(1000, 3500))
            .retryer(new Retryer.Default(5000, 5000, 3))
            .decoder(new JacksonDecoder())
            .encoder(new JacksonEncoder())
            .target(ClockClient.class,properties.getHost());
    }
}
